package hip.util.file;

import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.util.ResourceUtils;

import java.io.File;
import java.io.IOException;

public class FileResourceLoader {

    private static ResourceLoader loader = new DefaultResourceLoader();

    public static File getClassPathFile(String path) {

        Resource r = loader.getResource(ResourceUtils.CLASSPATH_URL_PREFIX + path);
        if (r.exists()) try {
            return r.getFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

}
